package com.kx.kxblog.service.impl;

import com.kx.kxblog.entity.AbstractEntity;
import com.kx.kxblog.service.AbstractService;
import org.springframework.data.jpa.repository.JpaRepository;

import javax.transaction.Transactional;

public abstract class AbstractServiceImpl<T extends AbstractEntity, ID,Dao extends JpaRepository<T, ID>> implements AbstractService<T, ID> {

    protected Dao dao;

    public T getById(ID id){
        return dao.findById(id).orElse(null);
    }

    @Transactional
    public T save(T entity){
        return dao.save(entity);
    }

}
